package com.qdxht.dispenser.utils;


import com.qdxht.dispenser.base.AppConfig;
import com.qdxht.dispenser.ui.models.entity.LoginEntity;
import com.qdxht.dispenser.ui.models.entity.UserInfoEntity;
import java.util.List;

/**
 * @author GJ
 * @Description:
 * @date 2022/6/11 16:40
 */
public class UserUtil {

    public static void saveLoginEntity(LoginEntity entity) {
       SpUtils.putObject("loginEntity", entity);
    }

    public static LoginEntity getLoginEntity() {
       return SpUtils.getObject("loginEntity", LoginEntity.class);
    }

    public static void removeLoginEntity() {
        SpUtils.removeKey("loginEntity");
    }

    public static String getSign(LoginEntity loginEntity, long time) {
        if(loginEntity != null) {
            String appId = AppConfig.getAppId();
            String appSecret = loginEntity.getAppSecret();
            String sign = appId +"&"+ appSecret +"&"+ time;
            return Md5.MD5(sign,"UTF-8").toLowerCase();
        }
        return null;
    }


    public static void saveUserInfo(UserInfoEntity entity) {
        SpUtils.putObject("userInfo", entity);
    }

    public static UserInfoEntity getUserInfo() {
        return SpUtils.getObject("userInfo", UserInfoEntity.class);
    }

    public static void removeUserInfo() {
        SpUtils.removeKey("userInfo");
    }

}
